let arr = [1,2,3,4,6,7,8]
console.info(getIndex(arr,3))

function getIndex(arr,a){
let left = 0;
let right = arr.length-1
while(left<=right){
  let mid = ~~((left+right)/2)
  console.info("mid"+mid)
 let temp = arr[mid]
  if(temp<a){
    left = mid+1 
  }else if(temp>a){
    right = mid-1
  }else {
    return mid 
  }

}
return -1}
